/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.vinisoft.gymwebapp.model.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author vinikike
 */
@Entity
@Table(name = "gym_rol")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GymRol.findAll", query = "SELECT g FROM GymRol g"),
    @NamedQuery(name = "GymRol.findById", query = "SELECT g FROM GymRol g WHERE g.id = :id"),
    @NamedQuery(name = "GymRol.findByDescripcion", query = "SELECT g FROM GymRol g WHERE g.descripcion = :descripcion")})
public class GymRol implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "id", nullable = false, length = 100)
    private String id;
    @Size(max = 500)
    @Column(name = "descripcion", length = 500)
    private String descripcion;
    @JoinTable(name = "gym_menu_rol", joinColumns = {
        @JoinColumn(name = "id_rol", referencedColumnName = "id", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "id_menu", referencedColumnName = "id", nullable = false)})
    @ManyToMany
    private List<GymMenu> gymMenuList;
    @OneToMany(mappedBy = "idRol")
    private List<GymUsuario> gymUsuarioList;

    public GymRol() {
    }

    public GymRol(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @XmlTransient
    public List<GymMenu> getGymMenuList() {
        return gymMenuList;
    }

    public void setGymMenuList(List<GymMenu> gymMenuList) {
        this.gymMenuList = gymMenuList;
    }

    @XmlTransient
    public List<GymUsuario> getGymUsuarioList() {
        return gymUsuarioList;
    }

    public void setGymUsuarioList(List<GymUsuario> gymUsuarioList) {
        this.gymUsuarioList = gymUsuarioList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GymRol)) {
            return false;
        }
        GymRol other = (GymRol) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.vinisoft.gymwebapp.model.entities.GymRol[ id=" + id + " ]";
    }
    
}
